<?php
// $Id$

/**
 * This file contains {@link AccessManager} which is part of the PHP Content Repository
 * (phpCR), a derivative of the Java Content Repository JSR-170,  and is 
 * licensed under the Apache License, Version 2.0.
 *
 * This file is based on the code created for
 * {@link http://www.jcp.org/en/jsr/detail?id=170 JSR-170}
 *
 * @author Travis Swicegood <travis@domain51.net>
 * @copyright PHP Code Copyright &copy; 2004-2005, Domain51, United States
 * @copyright Original Java and Documentation 
 *  Copyright &copy; 2002-2004, Day Management AG, Switerland
 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, 
 *      Version 2.0
 * @package phpContentRepository
 */

/**
 * Load the {@link phpCR} library file(s)
 */ 
require_once(dirname(__FILE__) . '/../phpCR.library.php');

/**
 * The access manager object.
 *
 * Level 2 only
 *
 * Acquired via {@link Workspace::getAccessManager()}.
 *
 * @see Workspace::getAccessManager()
 * @author PHP - Travis Swicegood <travis@domain51.net>
 * @copyright Copyright &copy; 2004-2005, Domain51
 * @package phpContentRepository
 */
interface AccessManager {
   /**
    * Returns the status of the item at $absPath regarding
    * the specified $permissions (under the rights held by current
    * {@link Ticket}). 
    *
    * @see Permission
    * @param string
    *   An absolute path to an {@link Item}.
    * @param int
    *   A combination of one or more of the following constants encoded as a 
    *   bitmask value:
    *   <ul>
    *       <li>{@link Permission::ADD_NODE}</li>
    *       <li>{@link Permission::SET_PROPERTY}</li>
    *       <li>{@link Permission::REMOVE_ITEM}</li>
    *       <li>{@link Permission::READ_ITEM}</li>
    *   </ul>
    * @return bool
    *   TRUE if $permissions are true for the 
    *   {@link Item} at $absPath; FALSE otherwise.
    *
    * @throws {@link PathNotFoundException}
    *   If no {@link Item} exists at $absPath.
    * @throws {@link RepositoryException}
    *   If an unexpected error occurs.
    * @throws {@link IllegalArgumentException}
    *   If $permissions specifies invalid permissions.
    */
    public function isGranted($absPath, $permissions);
    
    
   /**
    * Returns the set of permissions that are TRUE for the item
    * at $absPath.
    *
    * @see Permission
    * @param string
    *   An absolute path to an {@link Item}.
    * @return int
    *   A set of permissions encoded in a bitmask of permission constants 
    *   defined in {@link Permission}
    *
    * @throws {@link PathNotFoundException}
    *   If no {@link Item} exists at $absPath.
    * @throws {@link RepositoryException}
    *   If an unexpected error occurs.
    */
    public function getPermissions($absPath);
    
    
   /**
    * Returns an array of {@link Permission} objects describing all permissions 
    * supported by this repository.
    *
    * @return array
    *   An array of {@link Permission}s.
    */
    public function getSupportedPermissions();
}

